package cn.webrx;

import java.util.Random;
import java.util.UUID;

public class Rand1 {
    public static void main(String[] args) {
        //学习随机
        //01 随机小数double Math类的静态方法random();
        System.out.println(Math.random());

        //02 全球唯一随机字符串 import java.util.UUID;  36位字符串
        //89803063-a640-4ac7-a5ad-2fd06bf736ec
        String uuid = UUID.randomUUID().toString();
        System.out.println(uuid.length());
        System.out.println(uuid);
        System.out.println(uuid.toUpperCase());

        //03 随机类
        Random rand = new Random();
        //随机布尔（true | false)
        System.out.println(rand.nextBoolean());
        System.out.println(Math.random() > .5 ? true : false);

        //随机小数 0.34797225120449804
        System.out.println(rand.nextDouble());
        System.out.println(Math.random()); //0.33191567558058177
        //float  0.4006402
        System.out.println(rand.nextFloat());

        //随机整数范围
        //0-5 随机
        for (int i = 0; i < 10; i++) {
            //0-5 之间的随机整数
            //System.out.println(Math.round(Math.random()*5));

            //0-5 之间的随机整数，不包括6
            //System.out.println(rand.nextInt(6));

            //10 - 15之间的随机数
            System.out.println(rand.nextInt(10,16));
        }

    }
}
